<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>小广告</title>
		<style>
			
			#xgg{
				width: 10%;
				height: 10%;
				text-align: center;
				border: 1px solid black;
				position: absolute;
			}
		</style>
	</head>
	<body>
		<div id="xgg">小广告</div>
		<script>
			var xgg=document.getElementById('xgg');
			var w=window.innerWidth;
			var h=window.innerHeight;
			var dw=xgg.offsetWidth;
			var y=0;
			var x=0;
			var n=0;
			window.onload=function(){
				setInterval(myfun,100);
			}
			function myfun(){
				if(n==0){
						x=x+0.02*w;
						y=y+0.02*h;
						xgg.style.left=x+'px';
						xgg.style.top=y+'px';
						if((x+dw)>=w){
							n=1;
						}
				}else if(n==1){
						x=x-0.02*w;
						y=y-0.02*h;
						xgg.style.left=x+'px';
						xgg.style.top=y+'px';
						if(x<=0){
							n=0;
						}
				}
			}
		</script>
	</body>
</html>